package com.cgx.tablet.beeper.presenter;

import com.cgx.tablet.beeper.api.ApiCallback;
import com.cgx.tablet.beeper.api.ApiUtil;
import com.cgx.tablet.beeper.base.BasePresenter;
import com.cgx.tablet.beeper.bean.response.MsgResponse;
import com.cgx.tablet.beeper.view.IChangeStateView;


/**
 * 状态操作
 */

public class ChangeStatePresenter extends BasePresenter {

    private IChangeStateView view;

    public ChangeStatePresenter(IChangeStateView view) {
        super(view);
        this.view = view;
    }

    public void online() {
        callApi(ApiUtil.apiService.online(), new ApiCallback<MsgResponse>() {
            @Override
            public void onSuccess(final MsgResponse response) {
                view.onOnlineSuccess();
            }

            @Override
            public void onFail(String code, String msg) {
                view.onOnlineFail(code, msg);
            }
        });
    }

    public void stop() {
        callApi(ApiUtil.apiService.stop(), new ApiCallback<MsgResponse>() {
            @Override
            public void onSuccess(final MsgResponse response) {
                view.onStopSuccess();
            }

            @Override
            public void onFail(String code, String msg) {
                view.onStopFail(code, msg);
            }
        });
    }

    public void logout() {
        callApi(ApiUtil.apiService.logout(), new ApiCallback<MsgResponse>() {
            @Override
            public void onSuccess(final MsgResponse response) {
                view.onLogoutSuccess();
            }

            @Override
            public void onFail(String code, String msg) {
                view.onLogoutFail(code, msg);
            }
        });
    }
}
